
function go(){

 f1.submit();

 document.getElementById("p1").style.display="block";
 document.getElementById("prop").style.display="";
 timer=setInterval("getP()",50);

}
 
var xmlHttpRequest=false;
function getP(){
 
 if(window.XMLHttpRequest){
  xmlHttpRequest=new XMLHttpRequest();
 }else if(window.ActiveXObject){
	 try {
		 xmlHttpRequest=new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	}
  
 } 
  if(!xmlHttpRequest){
	  alert("不能创建XMLHttpRequest对象实例!");
	  return false;
  }
 xmlHttpRequest.onreadystatechange=callBack; 
 var url="getProgressServlet";
 xmlHttpRequest.open("post",url,true);
  
 xmlHttpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
 xmlHttpRequest.send("&timeStamp="+(new Date()).getTime()); 
  
}
//回调函数
function callBack(){
  
 if(xmlHttpRequest.readyState==4 && xmlHttpRequest.status==200){ 
   
  var results=xmlHttpRequest.responseText;
  var result=results.replace(/(^\s*)|(\s*$)/g, "");
  var res=results.split(",");
  var flag=res[1]; 
  var per=parseInt(res[0]);
  var err=res[2];

  document.getElementById("prop").innerHTML=per+"%";
  document.getElementById("progress").value=per;
 
  if(flag=="OK"){
   window.clearInterval(timer);
   
   alert("上传成功！");
   document.getElementById("prop").innerHTML="";
   document.getElementById("p1").style.display="none";
   f1.reset();
   
  }
  if(err!=""||err.length>0){
   window.clearInterval(timer);
   alert(err);
  }
  if(flag==null){
   window.clearInterval(timer);
  }
 }
}
